#!/usr/bin/env python

import os
from app import create_app, db
from app.models.account import Staff, DefPassword, User, Freeze, Upgrade
from app.models.business import Car, Business
from app.models.statistic import Daily_Statistic as DS
from app.models.application import Purchase_Application as PA, Business_Application as BA, Tracking, Advice
from app.models.risk_manage import Risk_Application as RA, Risk_Flow as RF, RiskPicture as RP
from app.models.site_setting import AttrBrand, AttrCarModel, Third_Party_Code as TPC
from flask_script import Manager, Shell
from flask_migrate import MigrateCommand
from app.models.site_setting import Carousel, HotCity, LinkSite, Navigation, Carousel_APP
from app.models.message import Message, MessageMiddle


app = create_app(os.getenv('MY_CONFIG') or 'default')
manager = Manager(app)

def make_shell_context():
    return dict(app=app, db=db, Staff=Staff, Car=Car, Business=Business,
                Carousel=Carousel,
                Navigation=Navigation,
                HotCity=HotCity,
                LinkSite=LinkSite,

		PA=PA, BA=BA, Tracking=Tracking, DefPassword=DefPassword, User=User,
                Message=Message, MessageMiddle=MessageMiddle,
    		Advice=Advice, Freeze = Freeze, Upgrade = Upgrade, DS=DS,
                RA=RA, RF=RF, AttrBrand=AttrBrand, AttrCarModel=AttrCarModel,
                TPC=TPC, RP=RP, Carousel_APP=Carousel_APP

                )


manager.add_command("shell", Shell(make_context=make_shell_context))
manager.add_command("db", MigrateCommand)

if __name__ == '__main__':
    manager.run()
